<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item>仓库</el-breadcrumb-item>
      <el-breadcrumb-item>仓库管理</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="box-card">
      <el-row>
        <el-table
          :data="
            inventory.slice(
              (currentPage - 1) * pagesize,
              currentPage * pagesize
            )
          "
          border
          style="width: 100%"
        >
          <!-- type="index" -->
          <el-table-column label="序号" width="80">
            <template slot-scope="scope">
              <span>{{ (currentPage - 1) * pagesize + scope.$index + 1 }}</span>
            </template>
          </el-table-column>
          <el-table-column label="件号">
            <template slot-scope="scope">
              <span>{{ scope.row.jianID }}</span>
            </template>
          </el-table-column>
          <el-table-column label="商品ID" width="80">
            <template slot-scope="scope">
              <span>{{ scope.row.pid }}</span>
            </template>
          </el-table-column>
          <el-table-column label="库位">
            <template slot-scope="scope">
              <span>{{ scope.row.kuwei }}</span>
            </template>
          </el-table-column>
        </el-table>
      </el-row>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="40"
      >
      </el-pagination>
    </el-card>
  </div>
</template>
<script>
import axios from "axios";
import { getAll, upsert, removed } from "../../network/InventoryManage.js";
export default {
  data() {
    return {
      inventory: [],
      query: "",
      currentPage: 1,
      pagesize: 5,
      state: "正常",
    };
  },
  created() {
    getAll()
      .then((res) => {
        var result = res.data.obj;
        this.inventory = result;
        console.log(res.data.obj);
      })
      .catch(function (error) {
        console.log(error);
      });
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    handleSizeChange(val) {
      this.pagesize = val;
    },
    handleCurrentChange(val) {
      this.currentPage = val;
    },
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
        })
        .catch((_) => {});
    },
    closed() {
      this.$refs.addFormRef.resetFields();
    },
  },
};
</script>

<style>
.el-breadcrumb {
  margin-bottom: 15px;
  font-size: 12px;
}
.btn {
  margin-left: 880px;
}
.el-table {
  margin-top: 15px;
}
.el-pagination {
  text-align: center;
}
</style>
